//
//  ViewController.m
// 简易测试首页
//  VPPublicUntilitisForPod
//
//  Created by verne on 2016/12/23.
//  Copyright © 2016年 vernepung. All rights reserved.
//

#import "ViewController.h"
#import "DownloadViewController.h"
#import "TestDownViewController.h"
#import "ScanViewController.h"
#import "UtilsMacro.h"
#import "ConstMacro.h"
#import "NSArray+Additional.h"
#import "VPJumpSettingViewController.h"
#import "VPRefreshExampleViewController.h"
#import "VPPresentViewController.h"
#import "VPRoundViewController.h"
#import "VPCheckViewController.h"
@interface ViewController ()<UITableViewDelegate, UITableViewDataSource>{
}
@property (strong, nonatomic) UITableView *homeTableView;
@property (strong, nonatomic) NSArray *datasource;

@end

@implementation ViewController
- (void)setStaticDatas {
    self.datasource = @[@"扫码",@"下载",@"设置",@"下拉刷新",@"modal",@"动画玩玩",@"检测Xib合法性"];
}

- (void)setupViews {
    [self.view addSubview:self.homeTableView];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.statusBarStype = VPStatusBarStyleDefault;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.datasource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"homeCellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    cell.textLabel.text = [self.datasource objectAtIndexChecked:indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSInteger row = indexPath.row;
    if (row == 0) {
        ScanViewController *vc = [[ScanViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if(row == 1){
        DownloadViewController *down = [DownloadViewController new];
        [self.navigationController pushViewController:down animated:YES];
    }else if(row == 2){
        VPJumpSettingViewController *jumpViewController = [[VPJumpSettingViewController alloc] init];
        [self.navigationController pushViewController:jumpViewController animated:YES];
    }else if(row == 3) {
        VPRefreshExampleViewController *vp = [[VPRefreshExampleViewController alloc] init];//]ViewControllerCanRefresh:YES canLoadMore:YES];
        [self.navigationController pushViewController:vp animated:YES];
    }else if(row == 4) {
        VPPresentViewController *vp = [[VPPresentViewController alloc] init];//]ViewControllerCanRefresh:YES canLoadMore:YES];
        [self.navigationController pushViewController:vp animated:YES];
    }else if(row == 5){
        VPRoundViewController *roundVC = [VPRoundViewController new];
        [self.navigationController pushViewController:roundVC animated:YES];
    }else if(row == 6){
        VPCheckViewController *checnVC = [VPCheckViewController new];
        checnVC.title = self.datasource[row];
        [self.navigationController pushViewController:checnVC animated:YES];
    }
}

#pragma mark - getter & setter
- (UITableView *)homeTableView {
    if (!_homeTableView) {
        _homeTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kMainBoundsWidth, kMainBoundsHeight - kNavBarHeightWithStatusBarHeight) style:UITableViewStylePlain];
        _homeTableView.delegate = self;
        _homeTableView.dataSource = self;
        _homeTableView.rowHeight = 49.f;
        _homeTableView.tableFooterView = [UIView new];
    }
    return _homeTableView;
}


@end
